﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <HEAD>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>工作计划  <{$smarty.const.WEB_NAME}></title>
	<link rel="stylesheet" type="text/css" href="./skin/default/style.css" />
	<script type="text/javascript" src="./skin/default/comm.js"></script> 
	<script type="text/javascript" src="./skin/default/calendar.js"></script>
	<style type="text/css">
		  body	{font-size:13px;}
	</style>
 </HEAD>

 <BODY>
 	<table width="100%">
 	<tr>
 		<td valign="top" width="100"  >
		   <div class="leftUserList" id="leftUserList">
			 <span class="tit">工作计划</span>
			 <ol>
				<{section name=loop loop=$departmentList}>
				<li> 
					<div>
						<a href="?q=workManage/viewWorkPlan&departmentId=<{$departmentList[loop].id}>"><{$departmentList[loop].name}></a>
					</div>
				</li>
				<{/section}>
			</ol>
		   </div>
		</td>
 	<td>
	  <table width="100%" border="1" cellspacing="0" bordercolor="#cfcfcd" cellpadding="0" class="tableList tip_bug" style="font-size:13px;">
		  <tr> 
		  <{if $smarty.session.type == 1}>
			<th width="50%" align="center"><a href="?q=workManage/viewWorkPlan">查看本部门工作计划</a></th>
			<th width="50%" align="center"><a href="#" onclick="AddWorkPlan()">新增本部门工作计划</a></th>
		  <{else}>
		    <th align="center"><a href="?q=workManage/viewWorkPlan">查看本部门工作计划</a></th>
		  <{/if}>
		  </tr>
	  </table>
	  <table width="100%" border="1" cellspacing="0" bordercolor="#cfcfcd" cellpadding="0" class="tableList tip_bug" style="font-size:13px;">
		  <tr> 
			<th width="5%" align="center">编号</th>
			<th width="40%" align="center">名称</th>
			<th width="7%" align="center">部门</th>
			<th width="10%" align="center">负责人</th>
			<th width="9%" align="center">开始时间</th>
			<th width="9%" align="center">结束时间</th>
			<th width="7%" align="center">状态</th>
			<th width="13%" align="center">操作</th>
		  </tr>
		  <{section name=workplan loop=$workPlanList}>
			<{assign var="planId" value=$workPlanList[workplan].id}>
			<{assign var="planName" value=$workPlanList[workplan].name}>
			<{assign var="deptid" value=$workPlanList[workplan].deptid}>
			<{assign var="deptName" value=$workPlanList[workplan].deptname}>
			<{assign var="userid" value=$workPlanList[workplan].userid}>
			<{assign var="userName" value=$workPlanList[workplan].username}>
			<{assign var="startTime" value=$workPlanList[workplan].starttime}>
			<{assign var="endTime" value=$workPlanList[workplan].endtime}>
			<{assign var="planState" value=$workPlanList[workplan].state}>
		  <tr>
			<td align="center"><{$planId}></td>
			<td>
			 <a href="?q=workManage/viewWorkPlanItem&workPlanId=<{$planId}>" id="planid_<{$planId}>"><{$planName}></a>
			</td>
			<td align="center"><{$deptName}></td>
			<td align="center"><{$userName}></td>
			<td align="center"><{$startTime}></td>
			<td align="center"><{$endTime}></td>
			<{if $planState == 0 }>
				<td align="center">进行中</td>
				<td align="center">
				<{if $smarty.session.id == $userid }>
				 <a href="#" onclick="UpdateWorkPlan(<{$planId}>, '<{$startTime}>', '<{$endTime}>')"><u>修改</u></a>
				 <a href="?q=workManage/doWorkPlan&action=close&workPlanId=<{$planId}>"><u>关闭</u></a>
				 <a href="javascript:GoDeleteUrl(<{$planId}>)"><u>删除</u></a>
				<{/if}>
				</td>
			<{else}>
				<td align="center">已关闭</td>
				<td align="center">
				<{if $smarty.session.id == $userid }>
				 <a href="#" onclick="UpdateWorkPlan(<{$planId}>, '<{$startTime}>', '<{$endTime}>')"><u>修改</u></a>
				 <a href="?q=workManage/doWorkPlan&action=open&workPlanId=<{$planId}>"><u>开启</u></a>
				 <a href="javascript:GoDeleteUrl(<{$planId}>)"><u>删除</u></a>
				<{/if}>
				</td>
			<{/if}>
		  </tr>
		  <{/section}>
	  </table>
	</td>
	</tr>
	</table>

	  <table id="editWorkPlan" border="1" cellspacing="0" bordercolor="#cfcfcd" cellpadding="0" class="msg_box driftWindow" style="font-size:13px; display:none; width:500px; left:320px; top:50px">
		<form method="post" name="editWorkPlanForm" id="editWorkPlanForm" onsubmit="return CheckWorkPlan()" action="?q=workManage/editWorkPlan">	
		 <tr class="tit">
		   <th align="center" colspan="2">编辑计划</th>
		   <input type="hidden" name="editPlanId" id='editPlanId' value="" />
		   <input type="hidden" name="editDeptId" value="<{$smarty.session.departmentId}>" />
		   <input type="hidden" name="editUserId" value="<{$smarty.session.id}>" />
		 </tr>
		 <tr>
			<td width="120" align="center">计划名称</td>
			<td height="50px">
				<textarea name="editPlanName" id="editPlanName" style="margin-left:20px; width:320px; height:40px; border:none; padding:6px; overflow:auto"></textarea>
			</td>
		 </tr>
		 <tr>
			<td width="120" align="center">开始时间</td>
			<td>
				<input type="text" name="editStartTime" id="editStartTime" value="" class="dateInput"  onclick="MyCalendar.SetDate(this)" /> 
			</td>
		 </tr>
		 <tr>
			<td width="120" align="center">结束时间</td>
			<td>
				<input type="text" name="editEndTime" id="editEndTime" value="" class="dateInput"  onclick="MyCalendar.SetDate(this)" /> 
			</td>
		 </tr>
		 <tr>
			<td align="center" colspan="2">
			  <input type="submit" class="submit" value="提交">
			  <input type="button" value="关闭" onclick="HiddenEditWorkPlan()" class="submit"/>
			</td>
		 </tr>
		</form>
      </table>

	<script type="text/javascript">
	<!--
		function AddWorkPlan() {
			$('editPlanId').value = '';
			$('editPlanName').value = '';
			$('editStartTime').value = '';
			$('editEndTime').value = '';
			$('editWorkPlan').style.display = "block";
		}

		function UpdateWorkPlan(planId, startTime, endTime) {
			$('editPlanId').value = planId;
			$('editPlanName').value = $('planid_' + planId).innerText;
			$('editStartTime').value = startTime;
			$('editEndTime').value = endTime;
			$('editWorkPlan').style.display = "block";
		}

		function CheckWorkPlan() {
			var name = $('editPlanName').value;
			name = name.trim();
			if( name.length <= 5 ) {
				window.alert( "计划名称太短了，请认真填写!" );
				return false;
			}

			var startTime = $('editStartTime').value;
			var endTime = $('editEndTime').value;
			if( startTime.trim().length < 8 ) {
				window.alert( "请选择开始时间!" );
				return false;
			} else if( endTime.trim().length < 8 ) {
				window.alert( "请选择结束时间!" );
				return false;
			} 
			
			if( startTime >= endTime ) {
				window.alert( "开始时间不能大于或等于结束时间!" );
				return false;
			}

			return true;
		}

		function HiddenEditWorkPlan() {
			$('editWorkPlan').style.display = "none";
		}

		function GoDeleteUrl( planId ) {
			if( confirm( "你确认要删除吗?") ) {
				location.href = "?q=workManage/doWorkPlan&action=delete&workPlanId=" + planId;
			}
		}
	//-->
	</script>
 </BODY>
</HTML>
